package com.xinxin.leetcode.problem485;

/**
 * @author ShiXinXin
 * @date 2020-01-06 11:05
 */
class Solution {
    public int findMaxConsecutiveOnes(int[] nums) {
        int max = 0;
        int sum = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 1) {
                sum++;
            } else {
                max = Math.max(max, sum);
                sum = 0;
            }
        }
        return Math.max(max, sum);
    }

    public static void main(String[] args) {
        int[] arr = {1, 1, 0, 1, 1, 1};
        System.out.println(new Solution().findMaxConsecutiveOnes(arr));
    }
}
